require "import"
import "com.androlua.*"
import "android.widget.*"
layout={
GridView,
id="grid",
numColumns=2,
layout_width="fill",
layout_height="fill"
}
items={"Bluetooth", "wifi", "Đèn pin", "dữ liệu di động", "âm thanh hoặc rung"}
dlg=LuaDialog(this)
dlg.View=loadlayout(layout)
grid.adapter=SingleLineAdapter(service, String(items))
dlg.setTitle ("chức năng đặc biệt")
dlg.show()
grid.onItemClick=function(l,v)
dlg.dismiss()
task(100, function()
if v.text == "click vào đây để tham gia nhóm cộng đồng jieshuo việt nam nhé!" then service.openUrl(
"https://t.me/+4MDkmPC3YIcxODRl"
)
elseif v.text == "Bluetooth" then
require "import"
import "android.bluetooth.BluetoothAdapter"
local bt= BluetoothAdapter.getDefaultAdapter()
if bt.isEnabled() == true then
bt.disable()
this.speak(" đã tắt bluetooth ") 
elseif bt.isEnabled() == false then
bt.enable()
this.speak(" đã bật bluetooth ")
end
elseif v.text == "wifi" then
require "import"
import "android.net.wifi.WifiManager"
local bt= this.getSystemService(this.WIFI_SERVICE) 
if bt.isWifiEnabled() == true then
bt.setWifiEnabled(false)
this.speak(" đã tắt Wifi  ") 
elseif bt.isWifiEnabled() == false then
bt.setWifiEnabled(true)
this.speak(" đã bật Wifi  ")
end
elseif v.text == "Đèn pin" then
if RFirst then
RFirst = 1;
else
RFirst = 2;
end
if RFirst == 2 then
RCount = 1;
end
if RFirst == 1 then
RCount = RCount+1;
end
if RCount > 2 then
RCount = 1
end
if RCount == 1 then 
require "import"
task(100,function()
require "import"
import "android.content.Context"
import "android.content.pm.PackageManager"
import "android.hardware.camera2.*"
import "android.os.Build"
import "android.os.Bundle"
import "java.util.jar.Manifest"
import "android.provider.*"

local hasFlash = service.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
local cameraManager  = service.getSystemService(this.CAMERA_SERVICE)
local cameraId = cameraManager.cameraIdList[0]

cameraManager.setTorchMode(cameraId,true)
service.speak(" đã bật đèn pin ")
return true
end)
else
if RCount == 2 then  
task(100,function()
require "import"
import "android.content.Context"
import "android.content.pm.PackageManager"
import "android.hardware.camera2.*"
import "android.os.Build"
import "android.os.Bundle"
import "java.util.jar.Manifest"
import "android.provider.*"

local hasFlash = service.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
local cameraManager  = service.getSystemService(this.CAMERA_SERVICE)
local cameraId = cameraManager.cameraIdList[0]

cameraManager.setTorchMode(cameraId,false)
service.speak(" đã tắt đèn pin")
return true
end)
end
end
elseif v.text == "dữ liệu di động" then
require "import"
import "android.content.*"
import "android.provider.*"
this.startActivity(Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY))
task(500,function()
service.click({{
"*di động$1",
"Xong"
}})
return true
end)elseif v.text == "âm thanh hoặc rung" then
require "import";
import "android.content.Context"
import "android.media.AudioManager"
import "com.androlua.*"
local audioManager=service.getSystemService(this.AUDIO_SERVICE)
local audioMode = audioManager.getRingerMode()
if audioMode == 1 then
audioManager.setRingerMode(audioManager.RINGER_MODE_NORMAL)
service.speak ("đã bật chế độ chuông")
elseif audioMode == 2 then
audioManager.setRingerMode(audioManager.RINGER_MODE_VIBRATE)
this.speak("đã bật chế độ rung")
end
return true end
end)
end